﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem
{
    /// <summary>
    /// NavigateWin.xaml 的交互逻辑
    /// </summary>
    public partial class NavigateWin : NavigationWindow
    {
        private static NavigateWin _navigation;
        private Page _navigatePage;

        public static NavigateWin Navigation
        {
            get
            {
                if (_navigation == null)
                {
                    _navigation = new NavigateWin();
                }
                return _navigation;
            }
        }

        public NavigateWin()
        {
            InitializeComponent();
            this.Left = 0;
            this.Top = 0;
            this.Height = SystemParameters.WorkArea.Height;
            this.Width = SystemParameters.WorkArea.Width;
            NavigationService.LoadCompleted += NavigationService_LoadCompleted;
            this.Loaded += NavigateWin_Loaded;
        }

        private void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
        {
            if (_navigation.NavigationService.Content is CommonPage)
                NavigateManager.Instance.Page = _navigation.NavigationService.Content as CommonPage;
        }

        private void NavigateWin_Loaded(object sender, RoutedEventArgs e)
        {

        }

        public void Back()
        {
            if (_navigation.NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
                
            }
        }
        public void ToPage(Object page)
        {
            NavigationService.Navigate(page);
        }
    }
}
